import { find, assign } from 'lodash'
import { auth } from '../servicePath'

const users = [
  { username: 'admin', password: 'admin', uuid: 'admin-uuid', name: 'Admin' },
  { username: 'editor', password: 'editor', uuid: 'editor-uuid', name: 'Editor' },
  { username: 'user1', password: 'user1', uuid: 'user1-uuid', name: 'User1' }
]

export default ({ service, request, serviceForMock, requestForMock, mock, faker, tools }) => ({

  GET_KAPTCHA () {
    return request({
      url: `${auth}/admin/kaptcha`,
      method: 'GET'
    })
  },
  /**
   * @description 登录
   * @param {Object} data 登录携带的信息
   */
  SYS_USER_LOGIN (data = {}) {
    return request({
      url: `${auth}/admin/login`,
      method: 'POST',
      data
    })
  },
  /**
   * 退出登录
   * @returns {*}
   * @constructor
   */
  SYS_USER_LOGOUT () {
    return request({
      url: `${auth}/admin/logout`,
      method: 'GET'
    })
  },
  // 获取用户列表
  GET_USER_LIST (data = {}) {
    return request({
      url: `${auth}/admin/admin/getPageList`,
      method: 'POST',
      params: data
    })
  },
  GET_USER (id) {
    return request({
      url: `${auth}/admin/admin/get`,
      method: 'POST',
      params: {id}
    })
  },
  // 新增用户
  ADD_USER (data = {}) {
    return request({
      url: `${auth}/admin/admin/add`,
      method: 'POST',
      data
    })
  },
  // 删除用户
  DELETE_USER (data = {}) {
    return request({
      url: `${auth}/admin/admin/delete`,
      method: 'POST',
      data
    })
  },
  // 更新用户
  UPDATE_USER (data = {}) {
    return request({
      url: `${auth}/admin/admin/update`,
      method: 'POST',
      data
    })
  },
  // 获取所有管理员列表
  GET_ALL_ADMIN (data = {}) {
    return request({
      url: `${auth}/admin/admin/getAllAdmin`,
      method: 'POST',
      data
    })
  },
  // 更新用户
  CHANGE_PWD (data = {}) {
    return request({
      url: `${auth}/admin/changePassword`,
      method: 'POST',
      data
    })
  }
})
